package guggaTests.utils
{
	import flexunit.framework.TestCase;
	import flash.utils.Timer;
	import gugga.utils.DoLaterUtil;
	import gugga.utils.DelayedCallTimeout;
	import flash.events.Event;
	import flash.events.TimerEvent;

	public class DelayedCallTimeoutTest extends TestCase
	{
		private var mIsMethodExecuted : Boolean = false;
		
		public function DelayedCallTimeoutTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public function testDelayedCall() : void
		{
			
			var timer : Timer = new Timer(200);
			timer.addEventListener(TimerEvent.TIMER, addAsync(checkIsMethodExecuted, 450))
			var delay : DelayedCallTimeout = new DelayedCallTimeout(10, this, method);
			timer.start();
		}
		
		private function checkIsMethodExecuted(aObject : Object) : void
		{
			assertTrue(
				"method was not executed",
				mIsMethodExecuted
				)
		}
		
		private function method() : void
		{
			mIsMethodExecuted = true;
		}
	}
}